package com.jwaoo.mobile.common.listener;

import android.view.View;

import com.dx.as.JWCache;
import com.dx.as.buriedpoint.bean.EventInfo;
import com.dx.as.db.IDBListener;
import com.dx.as.db.SqlLiteHelper;
import com.dx.as.utils.DateUtil;
import com.jwaoo.mobile.db.AppDatabase;

/**
 * Created by jwaoo on 2017/6/19.
 */

public abstract class JWOnClickListener implements View.OnClickListener{
    @Override
    public void onClick(View v) {
        Object object = v.getTag();
        if (object != null){
            final String tag = object.toString();
            SqlLiteHelper.getInstance(v.getContext().getApplicationContext()).dbOption(AppDatabase.class,new IDBListener<AppDatabase>(){
                @Override
                public void onOption(AppDatabase database) {
                    EventInfo eventInfo = new EventInfo();
                    eventInfo.setUuid(JWCache.getAccount());
                    eventInfo.setHappen_time(DateUtil.getGMTUnixTimeByCalendar());
                    eventInfo.setTag(tag);
                    database.actionsDao().insertEventInfo(eventInfo);
                }
            });
        }
    }
}
